<div class="layui-card">
    <div class="layui-card-header">
        <h2 class="header-title" id="tableName">数据表字段</h2>
        <span class="layui-breadcrumb pull-right">
          <a href="#!console">首页</a>
          <a><cite>数据表字段</cite></a>
        </span>
    </div>
    <div class="layui-card-body">
        <div class="layui-form toolbar">
            搜索：
            <select id="db-search-key">
                <option value="">-请选择-</option>
                <option value="table_name">字段名</option>
                <option value="note">备注</option>
            </select>&emsp;
            <input id="db-search-value" class="layui-input search-input" type="text" placeholder="输入关键字"/>&emsp;
            <button id="db-btn-search" class="layui-btn icon-btn"><i class="layui-icon">&#xe615;</i>搜索</button>
            <button id="db-btn-export" class="layui-btn icon-btn"><i class="layui-icon">&#xe601;</i>导出</button>
        </div>

        <table class="layui-table" id="table-field" lay-filter="table-field"></table>
    </div>
</div>


<!-- 表格操作列 -->
<script type="text/html" id="table-field-bar">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="details"><span class="layui-icon layui-icon-about"
                                                                                 title="详情"></span></a>
</script>

<script>
    layui.use(['form', 'table', 'util', 'config', 'admin'], function () {
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var layer = layui.layer;
        var util = layui.util;
        var admin = layui.admin;

        let dbTable = admin.getTempData("t_db_table");
        $("#tableName").html(dbTable.tableName);

        let db = admin.getTempData("t_db");
        // 渲染表格
        var renderTable = function () {
            table.render({
                elem: '#table-field',
                // url: config.base_server + 'user_query.json',
                url: config.base_server + 'api-db/tableField/getTableFieldList',
                method: 'GET',
                where: {
                    access_token: config.getToken().access_token,
                    dbTable: JSON.stringify(dbTable),
                    db:JSON.stringify(db)
                },
                page: true,
                cols: [[
                    {type: 'numbers'},
                    {field: 'fieldName', title: '字段名'},
                    {field: 'fieldType', title: '字段类型'},
                    {field: 'fieldLength', title: '字段长度'},
                    {field: 'note', title: '备注'}
                ]]
            });
        };
        renderTable();
    });
</script>